﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AForge.Genetic;
namespace dto
{
  public  class doubleCFunktionFct:IFitnessFunction
    {

        double IFitnessFunction.Evaluate(IChromosome chromosome)
        {
            myDoubleArrayChromosome chromosome1 = (myDoubleArrayChromosome)chromosome;
            double result=0;
            for (int i = 1; i < chromosome1.Length; i++)
            {
                for (int j = i + 1; j < chromosome1.Length + 1; j++)
                {
                    result += Math.Abs(chromosome1.Value[j - 1] - chromosome1.Value[i - 1]) / (double)(j - i);
                }
            }
            return (1/((2 * result)));
        }
    }
}
